#include <iostream>
using namespace std;

#include<stack>
#include<queue>

#include"Stack.h"
#include"Queue.h"
#include"PriorityQueue.h"
void test_stack()
{

	//bit::stack<int, deque<int>> s;
	//bit::stack<int, list<int>> s;
	bit::stack<int, vector<int>> s;
	s.push(1);
	s.push(2);
	s.push(3);
	s.push(4);

	while (!s.empty())
	{
		cout << s.top() << " ";
		s.pop();
	}
	cout << endl;
}

void test_queue()
{
	bit::queue<int> q;

	q.push(1);
	q.push(2);
	q.push(3);
	q.push(4);

	while (!q.empty())
	{
		cout << q.front() << " ";
		q.pop();
	}

	cout << endl;
}

void test_op1()
{
	srand(time(0));
	const int N = 1000000;

	deque<int> dq;
	vector<int> v;

	for (int i = 0; i < N; ++i)
	{
		auto e = rand() + i;
		v.push_back(e);
		dq.push_back(e);
	}

	int begin1 = clock();
	sort(v.begin(), v.end());
	int end1 = clock();

	int begin2 = clock();
	sort(dq.begin(), dq.end());
	int end2 = clock();

	printf("vector:%d\n", end1 - begin1);
	printf("deque:%d\n", end2 - begin2);
}

void test_op2()
{
	srand(time(0));
	const int N = 10000;

	deque<int> dq1;
	deque<int> dq2;

	for (int i = 0; i < N; ++i)
	{
		auto e = rand() + i;
		dq1.push_back(e);
		dq2.push_back(e);
	}

	int begin1 = clock();
	sort(dq1.begin(), dq1.end());
	int end1 = clock();

	int begin2 = clock();
	vector<int> v(dq2.begin(), dq2.end());
	sort(dq2.begin(), dq2.end());
	dq2.assign(v.begin(), v.end());
	int end2 = clock();

	printf("deque sort:%d\n", end1 - begin1);
	printf("deque copy vector sort, copy back deque:%d\n", end2 - begin2);
}

void test_priority_queue()
{
	vector<int> v = { 3,2,7,6,0,4,1,9,8,5 };
	/*priority_queue<int> q1;
	for (auto& e : v)
	{
		q1.push(e);
	}*/

	//priority_queue<int> q1(v.begin(), v.end());

	int a[] = { 3,2,7,6,0,4,1,9,8,5 };
	//bit::priority_queue<int> q1(a, a + sizeof(a) / sizeof(int));
	bit::priority_queue<int, vector<int>, bit::mygreater<int>> q1(a, a + sizeof(a) / sizeof(int));

	while (!q1.empty())
	{
		cout << q1.top() << " ";
		q1.pop();
	}
	cout << endl;
}

void Push_back(int x)
{
	cout << "void Push_back(int x)" << endl;
}

struct Vector
{
	void(*push_back) (int);

};

void Init(struct Vector* pv)
{
	pv->push_back = Push_back;
}
//
//int main()
//{
//	Vector v;
//	Init(&v);
//
//	v.push_back(1);
//	v.push_back(2);
//	return 0;
//}

//int main()
//{
//	//test_stack();
//	//test_queue();
//
//	//test_op1();
//	//test_op2();
//
//	test_priority_queue();
//
//	return 0;
//}
//


class Date
{
public:
	Date(int year = 1900 , int month = 1 ,int day = 1)
		:_year(year)
		,_month(month)
		,_day(day)
	{}

	bool operator < (const Date& d) const
	{
		return (_year < d._year) ||
			(_year == d._year && _month < d._month) ||
			(_year == d._year && _month == d._month && _day < d._day);
	}

	bool operator == (const Date& d) const
	{
		return (_year == d._year) &&
			(_month == d._month) &&
			(_day == d._day);
	}

	bool operator > (const Date& d) const
	{
		return (_year > d._year) ||
			(_year == d._year && _month > d._month) ||
			(_year == d._year && _month == d._month && _day > d._day);
	}

	friend ostream& operator << (ostream& _cout, const Date& d);
private:
	int _year;
	int _month;
	int _day;
};


ostream& operator << (ostream& _cout, const Date& d)
{
	_cout << d._year << "-" << d._month << "-" << d._day << endl;
	return _cout;
}

struct PDate_less
{
	bool operator () (Date* x,Date* y)
	{
		return *x < *y;
	}
};

void TestPriority_queue()
{
	bit::priority_queue<Date*, vector<Date*>, PDate_less> q1;
	q1.push(new Date(2024, 7, 13));
	q1.push(new Date(2024, 7, 14));
	q1.push(new Date(2024, 7, 15));

	while (!q1.empty())
	{
		cout << *q1.top() ;
		q1.pop();
	}
	cout << endl;
}

int main()
{
	TestPriority_queue();

	return 0;
}